import { defineStore } from 'pinia';
export const useOrderStore = defineStore('order', {
    state: () => ({   // 共享的状态
        orderNum:22,
        orderState: 2,
    }),
    getters: {  // 对于共享状态的二次处理函数 返回的是函数的返回值(约等于计算属性)
        orderTxt(){
            if(this.orderState === 1 ) return '待支付'
            if(this.orderState === 2 ) return '已支付'
            if(this.orderState === 3 ) return '已发货'
            return '其他'
        }
    },
    actions: {
        changeOrderNum(){
            this.orderNum++
        },
        setOrderState( res ){
            this.orderState  = res
        }
    }
})